<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>帖子列表</title>
    <link rel="stylesheet" th:href="@{/css/style.css}">
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/css/bootstrap-pager.css}">
</head>
<body>
    <h1>帖子列表</h1>
    <table>
        <thead>
            <tr>
                <th>帖子ID</th>
                <th>标题</th>
                <th>作者</th>
                <th>发布时间</th>
                <th>回复次数</th>
            </tr>
        </thead>
        <tbody>
            <tr th:each="detail : ${result.records}">
                <td th:text="${detail.id}">100</td>
                <td th:text="${detail.title}">如何学好编程？</td>
                <td th:text="${detail.author}">丁XX</td>
                <td th:text="${#dates.format(detail.createDate,'yyyy-MM-dd')}">2012-10-11</td>
                <td th:text="${detail.replyCount}">200</td>
            </tr>
        </tbody>
    </table>
    <nav aria-label="Page navigation">
        <ul class="pagination">
            <li th:class="${result.current==1?'disabled':''}">
                <a th:href="@{'/detail2/page/'+${result.current - 1}}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <li th:if="${result.current > 2}"><a th:href="@{'/detail2/page/'+${result.current - 2}}" th:text="${result.current - 2}">1</a></li>
            <li th:if="${result.current > 1}"><a th:href="@{'/detail2/page/'+${result.current - 1}}" th:text="${result.current - 1}">2</a></li>
            <li><a class="active" href="#" th:text="${result.current}">3</a></li>
            <li th:if="${result.pages - result.current > 0}"><a th:href="@{'/detail2/page/'+${result.current + 1}}" th:text="${result.current + 1}">4</a></li>
            <li th:if="${result.pages - result.current > 1}"><a th:href="@{'/detail2/page/'+${result.current + 2}}" th:text="${result.current + 2}">5</a></li>
            <li th:class="${result.current==result.pages?'disabled':''}">
                <a th:href="@{'/detail2/page/'+${result.current + 1}}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        </ul>
    </nav>

    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
</body>
</html>